package org.example.erp.utils;
import java.time.LocalDate;

public class UtilMethod {
    private static final String STR_NUM = "0123456789";

    /**
     * 获取随机字符串
     * @param prefix 前缀
     * @return 随机字符串
     */
    public static String getRndomString(String prefix){
        StringBuilder stringBuilder = new StringBuilder(prefix);
        LocalDate now = LocalDate.now();
        stringBuilder.append(now.getYear())
                .append(String.format("%02d",now.getMonthValue()))
                .append(String.format("%02d",now.getDayOfMonth()));
        for (int i = 0; i < 6; i++) {
            int index = (int)(Math.random() * STR_NUM.length());
            stringBuilder.append(STR_NUM.charAt(index));
        }
        return stringBuilder.toString();
    }
}
